package com.ruoyi.web.controller.wuyi;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.wuyi.domain.XiaoshouInfo;
import com.ruoyi.wuyi.service.IXiaoshouInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 售卖信息Controller
 * 
 * @author ruoyi
 * @date 2021-07-06
 */
@RestController
@RequestMapping("/system/sell")
public class XiaoshouInfoController extends BaseController
{
    @Autowired
    private IXiaoshouInfoService xiaoshouInfoService;

    /**
     * 查询售卖信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:sell:list')")
    @GetMapping("/list")
    public TableDataInfo list(XiaoshouInfo xiaoshouInfo)
    {
        startPage();
        List<XiaoshouInfo> list = xiaoshouInfoService.selectXiaoshouInfoList(xiaoshouInfo);
        return getDataTable(list);
    }

    /**
     * 导出售卖信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:sell:export')")
    @Log(title = "售卖信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(XiaoshouInfo xiaoshouInfo)
    {
        List<XiaoshouInfo> list = xiaoshouInfoService.selectXiaoshouInfoList(xiaoshouInfo);
        ExcelUtil<XiaoshouInfo> util = new ExcelUtil<XiaoshouInfo>(XiaoshouInfo.class);
        return util.exportExcel(list, "售卖信息数据");
    }

    /**
     * 获取售卖信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:sell:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(xiaoshouInfoService.selectXiaoshouInfoById(id));
    }

    /**
     * 新增售卖信息
     */
    @PreAuthorize("@ss.hasPermi('system:sell:add')")
    @Log(title = "售卖信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody XiaoshouInfo xiaoshouInfo)
    {
        return toAjax(xiaoshouInfoService.insertXiaoshouInfo(xiaoshouInfo));
    }

    /**
     * 修改售卖信息
     */
    @PreAuthorize("@ss.hasPermi('system:sell:edit')")
    @Log(title = "售卖信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody XiaoshouInfo xiaoshouInfo)
    {
        return toAjax(xiaoshouInfoService.updateXiaoshouInfo(xiaoshouInfo));
    }

    /**
     * 删除售卖信息
     */
    @PreAuthorize("@ss.hasPermi('system:sell:remove')")
    @Log(title = "售卖信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(xiaoshouInfoService.deleteXiaoshouInfoByIds(ids));
    }
}
